package com.tj.bo.user.server.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.tj.bo.user.server.dao.UserPromotionRecordDao;
import com.tj.bo.user.server.entity.UserPromotionRecordEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* User: xulin
* Date: 2020-08-19
* Time: 18:16:04.891
*/

@Repository
public class UserPromotionRecordDaoImpl extends AbstractBaseMapper<UserPromotionRecordEntity> implements UserPromotionRecordDao {


    @Override
    public List<UserPromotionRecordEntity> queryUserPromotionRecordByUserCode(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().selectList(this.getStatement("queryUserPromotionRecordByUserCode"), params);
    }

    @Override
    public UserPromotionRecordEntity queryUserPromotionByInvitedUserCode(String invitedUserCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("invitedUserCode", invitedUserCode);
        return getSqlSession().selectOne(this.getStatement("queryUserPromotionByInvitedUserCode"), params);
    }

    @Override
    public int updateUserPromotionRecord(String invitedUserCode, Integer bonus) {
        Map<String, Object> params = new HashMap<>();
        params.put("bonus", bonus);
        params.put("invitedUserCode", invitedUserCode);
        params.put("status", 1);
        return getSqlSession().update(this.getStatement("updateUserPromotionRecord"), params);
    }
}